<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="content-type" content="application/json;charset=utf-8">
    <script type="text/javascript" src="/js/jquery-3.2.1.min.js">
    </script>
    <script scriptCharset="UTF-8">
        function requestByJson() {
            $.ajax({
                type : 'POST',
                url : 'ajax',
                //设置contentType类型为json
                contentType : 'application/json;charset=utf-8',
                //json数据
                data : '{"id":234,"userName":"张三","password":"123456","age":12}',
                //请求成功后的回调函数
                success : function(data) {
                    alert(data.userName);
                }
            });
        }
    </script>
</head>
<body>
<p>${pageContext.request.contextPath}</p>
<input type="button" value="json" onclick="requestByJson()">
</body>
</html>
